/**
 * 首页的左侧区域
 */
Ext.define('app.view.main.region.Left', {

	extend: 'Ext.panel.Panel',
	
	alias: 'widget.mainleft',
	
	uses: [
		'app.view.main.layout.MainTreeLayout',
		'app.view.main.layout.MainAccordionLayout'
	],
	
	layout : 'fit',
	
	glyph : 0xf0c9,
	
	tools: [{
		type: 'pin',
		tooltip: '层叠方式显示菜单',
		listeners: {
			click: function(tool) {
				var panel = tool.up('mainleft');
				panel.insert(0, {
					xtype : 'mainaccordion'					
				});
				panel.items.items[0].expand();
				panel.remove(panel.down('maintree'), true);
				tool.hide();
				tool.nextSibling().show();
			}
		}
	}, {
		type: 'unpin',
		tooltip : '树状方式显示菜单',
		hidden : true,
		listeners : {
			click : function(tool) {
				var panel = tool.up('mainleft');
				panel.insert(0, {
					xtype : 'maintree'
				});

				panel.items.items[0].expand();
				Ext.each(panel.query('mainaccordion'), function(accordion) {
					panel.remove(accordion, true)
				})
				tool.hide();
				tool.previousSibling().show();
			}
		}
	}],
	
	initComponent: function() {
		this.items = [{
			xtype : 'maintree'
		}];
		
		this.callParent();
	}
}); 